home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / computerjanitor / package_cruft.py < prev    next >
Encoding:
Python Source  |  2009-04-27  |  1.8 KB  |  58 lines

  1. # package_cruft.py - implementation for the package craft 
  2. # Copyright (C) 2008  Canonical, Ltd.
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, version 3 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  15.  
  16.  
  17. import computerjanitor
  18. _ = computerjanitor.setup_gettext()
  19.  
  20.  
  21. class PackageCruft(computerjanitor.Cruft):
  22.  
  23.     """Cruft that is .deb packages.
  24.     
  25.     This type of cruft consists of .deb packages installed onto the
  26.     system which can be removed. Various plugins may decide that
  27.     various packages are cruft; they can all use objects of PackageCruft
  28.     type to mark such packages, regardless of the reason the packages
  29.     are considered cruft.
  30.     
  31.     When PackageCruft instantiated, the package is identified by an
  32.     apt.Package object. That object is used for all the real operations,
  33.     so this class is merely a thin wrapper around it.
  34.     
  35.     """
  36.  
  37.     def __init__(self, pkg, description):
  38.         self._pkg = pkg
  39.         self._description = description
  40.  
  41.     def get_prefix(self):
  42.         return "deb"
  43.  
  44.     def get_prefix_description(self):
  45.         return _(".deb package")
  46.  
  47.     def get_shortname(self):
  48.         return self._pkg.name
  49.  
  50.     def get_description(self):
  51.         return "%s\n\n%s" % (self._description, self._pkg.summary)
  52.  
  53.     def get_disk_usage(self):
  54.         return self._pkg.installedSize
  55.  
  56.     def cleanup(self):
  57.         self._pkg.markDelete()
  58.